//
//  BNVisitorVC.swift
//  BNWeiBo
//
//  Created by ba.o0 on 16/8/10.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit


class BNVisitorVC: UIViewController {

    //6.1
    //判断用户是否登录
    var isLogin:Bool = false
    
    //8.4
    //访客视图view
    var visitorView:BNVisitorView?
    
    //6.0
    override func loadView() {
        if isLogin{
           super.loadView()
        }else{
            setupVisitorView()
        }
    }
<<<<<<< HEAD
    //6.0
=======
    
>>>>>>> a7bd7b8df0ef6cde14b4fd9f5315e104b71c0711
    //MARK- 设置访客视图
    func setupVisitorView(){
        setupNav()
        visitorView = BNVisitorView()
<<<<<<< HEAD
        
        //10.3
        //02闭包的实例化
        visitorView?.closure = {
            //04监听事件
            self.loginAction()
        }
        
        view = visitorView
    }
    //6.0
=======
        view = visitorView
    }
    
>>>>>>> a7bd7b8df0ef6cde14b4fd9f5315e104b71c0711
    // 设置导航
    func setupNav(){
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target:self, action: "loginAction")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "loginAction")
    }
<<<<<<< HEAD
    //6.0
    //MARK: - 监听方法
    func loginAction(){
        
        //11.1
        let oauthVC = BNOAuthVC()
        
    presentViewController(UINavigationController(rootViewController: oauthVC),animated: true,completion: nil)
        
=======
    //MARK: - 监听方法
    func loginAction(){
        print("登录注册被点击了")
>>>>>>> a7bd7b8df0ef6cde14b4fd9f5315e104b71c0711
    }
    override func viewDidLoad() {
        super.viewDidLoad()
    }
}















